#include "print_sequence.h"
using std::string;
using std::ostream;

namespace
{


//8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

//		print_fasta

//			print new line every line_len amino acids

//8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

/*
string line_wrap(string ret, unsigned line_len)
{
	ret.reserve(ret.length() + ret.length() / line_len + 1);

	unsigned s_pos = line_len;
	while (s_pos < s.length())
	{
		s.insert(s_pos, "\n", 1);
		pos += line_len + 1;
	}
	return ret;
}
*/




string line_wrap(const string& s, unsigned line_len)
{
	string ret;
	if (line_len == string::npos)
	{
		ret = s;
		return ret;
	}

	ret.reserve(s.length() + s.length() / line_len + 1);
	unsigned s_pos = 0;
	while (s_pos + line_len < s.length())
	{
		ret += s.substr(s_pos, line_len);
		ret += '\n';
		s_pos += line_len;
	}
	ret += s.substr(s_pos);
	return ret;
}

}
void print_fasta(std::ostream& os, const string& accession, const string& sequence, unsigned line_len)
{
	os << ">" << accession << "\n";
	os << line_wrap(sequence, line_len) << "\n";
}




